package de.gameduell.framework.application {
	import flash.display.DisplayObjectContainer;
	import flash.display.Shape;
	import flash.display.Sprite;
	
	import de.gameduell.framework.gui.wrapper.SpriteWrapper;	

	public class Window extends SpriteWrapper {

		private var _frame:Sprite;
		private var _content:Sprite;
		private var _popupPlane:Sprite;
		
		/**  
		 * @param aSprite = the sprite of the "window" 
		**/
		public function Window(aSprite:Sprite) {
			super(aSprite);
			
			_frame 	 = _sprite.getChildByName("frame") as Sprite;
			_content = _sprite.getChildByName("content") as Sprite;
		
			createPopupPlane();		
			
			aSprite.tabChildren = false;
			aSprite.tabEnabled  = false;
			
			if(_frame != null){
				_frame.tabChildren = false;
			}
			_content.tabChildren = false;
			
		}
		
		/**  
		 * creates a shape in the size of the "window" and adds it to the popupplane
		 * 
		**/
		private function createPopupPlane():void{
			_popupPlane = new Sprite();
			var _blocker:Shape = new Shape();
			_blocker.graphics.drawRect(0, 0, sprite.width, sprite.height);
			_popupPlane.addChild(_blocker);
			_popupPlane.tabChildren = false;
			addChild(_popupPlane);
		}
		
		/**
		* @return Sprite returns the frame of the application
		*/
		public function getFrame():Sprite{
			return _frame;
		}
		
		/**
		* @return Sprite returns the content of the application
		*/
		public function getContent():Sprite{
			return _content;
		}
		
		/**
		* @return Sprite returns the popupPlane of the application
		*/
		public function getPopupPlane():Sprite{
			return _popupPlane;
		}
	}
}
